package top.soulblack.purchasesale.controller.wechat;

import com.alibaba.fastjson.JSONObject;

public class Result {

    private static String resultBuilder(Integer code,String msg,String url,String data){
        JSONObject result = new JSONObject();
        result.put("code",code);
        result.put("msg",msg);
        result.put("url",url);
        result.put("data",data);
        return result.toJSONString();
    }

    public static String error(String msg){
        return resultBuilder(-1,msg,"","");
    }

    public static String error(String msg,String url){
        return resultBuilder(-1,msg,url,"");
    }

    public static String error(String msg,String url,String data){
        return resultBuilder(-1,msg,url,data);
    }

    public static String success(String msg){ return resultBuilder(1,msg,"",""); }

    public static String success(String msg,String url){
        return resultBuilder(1,msg,url,"");
    }

    public static String success(String msg,String url,String data){
        return resultBuilder(1,msg,url,data);
    }
}
